home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / CURLPushButton 2.3 / CURLPushButton Test 68k / CURLTestDialog.cp < prev    next >
Encoding:
Text File  |  1997-07-21  |  2.7 KB  |  119 lines  |  [TEXT/CWIE]

  1. // CURLTestDialog.cp ©1997 John C. Daub.  All rights reserved.
  2.  
  3. //    This is the dialog handler used to demonstrate the CURLPushButton PowerPlant
  4. //    class.  It's just a hack to demonstrate, not necessarily good coding
  5. //    practice.
  6.  
  7. #include "CURLTestDialog.h"
  8. #include "CURLPushButton.h"
  9. #include <UModalDialogs.h>
  10. #include <LPane.h>
  11. #include <LWindow.h>
  12. #include <PP_Messages.h>
  13.  
  14. const ResIDT    PPob_Demo    =    128;
  15.  
  16. void
  17. CURLTestDialog::DoAboutBox( LCommander *inSuper )
  18. {
  19.     // get the dialog handler
  20.     
  21.     CURLTestDialog *theHandler = new CURLTestDialog( PPob_Demo, inSuper );
  22.     ThrowIfNil_(theHandler);
  23.     
  24.     // make the handler listen to the CURLPushButton's
  25.     // Isn't this just UGLY? :-)
  26.     
  27.     ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(1))->AddListener(theHandler);
  28.     ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(2))->AddListener(theHandler);
  29.     ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(3))->AddListener(theHandler);
  30.     ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(4))->AddListener(theHandler);
  31.     
  32.     // we want the last button to demo the use of InvertRect
  33.     
  34.     ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(4))->SetUseInvertRect(true);
  35.  
  36. #if _CURLPushButton_DO_DND_
  37.     // we want #2 to not support drag and drop
  38.     ((CURLPushButton*)(theHandler->GetDialog())->FindPaneByID(2))->SetDoDragAndDrop(false);
  39. #endif
  40.  
  41.     // show it and do it
  42.     
  43.     theHandler->GetDialog()->Show();
  44.     
  45.     MessageT theMessage;
  46.  
  47.     do {
  48.         theMessage = theHandler->DoDialog();
  49.     } while ( theMessage != msg_OK );
  50.     
  51.     delete theHandler;
  52. }
  53.  
  54. CURLTestDialog::CURLTestDialog( ResIDT inDialogResID, LCommander *inSuper )
  55.     : StDialogHandler( inDialogResID, inSuper )
  56. {
  57.     mICWorking = false; // assume failure
  58.     
  59.     mIC = new CInternetConfig( 'CüRL' ); // test application signature
  60.     
  61.     if ( mIC )
  62.     {
  63.         OSErr err;
  64.         
  65.         err = mIC->Start();
  66.         
  67.         if ( err == noErr )
  68.             mICWorking = true;
  69.         else
  70.             mICWorking = false;
  71.     }
  72.     else
  73.     {
  74.         mICWorking = false;
  75.     }
  76. }
  77.  
  78. CURLTestDialog::~CURLTestDialog()
  79. {
  80.     delete mIC;
  81.     mIC = nil;
  82. }
  83.  
  84. void
  85. CURLTestDialog::ListenToMessage( MessageT inMessage, void* ioParam )
  86. {
  87. #pragma unused (ioParam)
  88.  
  89.     mMessage = inMessage;  // store message for DoDialog to return
  90.     
  91.     Str255 theURL = "\p";
  92.     
  93.     if ( (mMessage == 'WWW ') && mICWorking )
  94.     {
  95.         ((CURLPushButton*)(GetDialog())->FindPaneByID(1))->GetURL(theURL);
  96.         mIC->DoURL( theURL );
  97.     }
  98.     
  99.     if ( (mMessage == 'MWww') && mICWorking )
  100.     {
  101.         ((CURLPushButton*)(GetDialog())->FindPaneByID(2))->GetURL(theURL);
  102.         mIC->DoURL( theURL );
  103.  
  104.     }
  105.  
  106.     if ( (mMessage == 'Mail') && mICWorking )
  107.     {
  108.         ((CURLPushButton*)(GetDialog())->FindPaneByID(3))->GetURL(theURL);
  109.         mIC->DoURL( theURL );
  110.     }
  111.     
  112.     if ( (mMessage == 'FTP ') && mICWorking )
  113.     {
  114.         ((CURLPushButton*)(GetDialog())->FindPaneByID(4))->GetURL(theURL);
  115.         mIC->DoURL( theURL );
  116.  
  117.     }
  118.     
  119. }